package GUILayer;

import java.awt.EventQueue;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class MainMenu
{

	private static MainMenu instance;
	private SupplierMenu supplierMenu;
	private CustomerMenu customerMenu;

	public JFrame frame;
	
	public static void main(String[] args)
	{
		EventQueue.invokeLater(new Runnable()
		{
			public void run()
			{
				try
				{
					MainMenu window = new MainMenu();
					window.frame.setVisible(true);
				} 
				catch (Exception e)
				{
					e.printStackTrace();
				}
			}
		});
	}

	private MainMenu()
	{
		initialize();
	}

	public static MainMenu getInstance()
	{
		if(instance==null)
		{
			instance = new MainMenu();
		}
		return instance;
		
	}
	
	private void initialize()
	{
		frame = new JFrame();
		frame.setBounds(100, 100, 450, 300);
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.getContentPane().setLayout(null);
		
		JButton btnCustomers = new JButton("Customers");
		btnCustomers.addActionListener(new ActionListener() 
		{
			public void actionPerformed(ActionEvent e) 
			{
				customerMenu=CustomerMenu.getInstance();
				customerMenu.frame.setVisible(true);
				customerMenu.frame.setState(JFrame.NORMAL);
				
				
			}
		});
		btnCustomers.setBounds(30, 20, 150, 50);
		frame.getContentPane().add(btnCustomers);
		
		JButton btnOrders = new JButton("Orders");
		btnOrders.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				OrderMenu order = OrderMenu.getInstance();
			}
		});
		btnOrders.setBounds(30, 90, 150, 50);
		frame.getContentPane().add(btnOrders);
		
		JButton btnProducts = new JButton("Products");
		btnProducts.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				
			}
		});
		btnProducts.setBounds(250, 20, 150, 50);
		frame.getContentPane().add(btnProducts);
		
		JButton btnExit = new JButton("Exit");
		btnExit.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0)
			{
				frame.dispose();
			}
		});
		btnExit.setBounds(30, 160, 370, 50);
		frame.getContentPane().add(btnExit);
		
		JButton btnNewButton = new JButton("Suppliers");
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) 
			{
				supplierMenu=SupplierMenu.getInstance();
				supplierMenu.frmSupplierInformation.setVisible(true);
				supplierMenu.frmSupplierInformation.setState(JFrame.NORMAL);
			}
		});
		btnNewButton.setBounds(250, 90, 150, 50);
		frame.getContentPane().add(btnNewButton);
	}
}
